package demo03;

//玩家类
class Player {
  private int x;
  private int y;
  private int health = 100;
  private int attack = 10;
  private int spellAttack = 10;
  private int armor = 0;
  private int ironSwords = 0;
  private int spellBooks = 0;
  private int armors = 0;

  public void move(int dx, int dy) {
      x += dx;
      y += dy;
  }

  // 处理各种事件的方法
  public void heal() {
      health = Math.min(health + 10, 100);
  }

  public void pickIronSword() {
      attack += 10;
      ironSwords++;
  }

  public void pickSpellBook() {
      spellAttack += 10;
      spellBooks++;
  }

  public void pickArmor() {
      armor += 20;
      armors++;
  }

  // 显示状态和背包
  public void showStatus() {
      System.out.println("=== 玩家状态 ===");
      System.out.println("血量: " + health);
      System.out.println("攻击力: " + attack);
      System.out.println("法术攻击: " + spellAttack);
      System.out.println("护甲: " + armor);
  }

  public void showBackpack() {
      System.out.println("=== 背包 ===");
      System.out.println("铁剑: " + ironSwords);
      System.out.println("大书: " + spellBooks);
      System.out.println("守护之铠: " + armors);
  }

  public int getX() { return x; }
  public int getY() { return y; }
}